<template>
  <!-- 红包弹层 -->
  <div v-show="value" class="red-packet-pop red-packet-big">
      <div v-show="showBg" class="bg"></div>

      <div flex="dir:top cross:center" class="content">
        <div class="title-placeholder"></div>
        <transition
          enter-active-class="animated fadeIn"
          leave-active-class="animated fadeOut">
          <div v-show="value" class="title">
            <slot name="title">
              <img v-if="money > 0" src="../assets/images/sm-red-package-title.png"/>
              <img v-else src="../assets/images/big-red-package-title.png"/>
            </slot>
          </div>
        </transition>

        <div class="body-top-placeholder"></div>
        <transition
          enter-active-class="animated bounceIn"
          leave-active-class="animated bounceOutRight">
        <div v-show="value" class="body">
          <slot name="body">
            <img v-if="money" src="../assets/images/red-packet-big.png" alt="">
            <img v-else src="../assets/images/red-packet-fu.png" alt="">
            <div v-if="money" class="money tc">{{(money || 0) / 100}}元</div>
          </slot>
        </div>
        </transition>
        <div class="body-bottom-placeholder"></div>

        <slot name="footer">
          <div @click="gotoRedPacket" class="btns">
            <img class="btn" src="../assets/images/see-btn.png"/>
            <img src="../assets/images/gesture.png" alt="" class="gesture">
          </div>
        </slot>

        <div v-show="logan || gap" class="btns-bottom-placeholder"></div>
        <p v-show="logan" class="logan tc"><img src="../assets/images/jq8.png" alt=""></p>
      </div>

  </div>
</template>

<script>
  export default {
    props: {
      type: {
        default: 'bag',
        require: true,
        type: String
      },
      money: {
        type: Number,
        default: 0
      },
      value: {
        default: false,
        require: true,
        type: Boolean
      },
      logan: {
        default: true,
        type: Boolean
      },
      showBg: {
        default: true,
        type: Boolean
      },
      gap: {
        default:false,
        type: Boolean
      }
    },
    methods: {
      gotoRedPacket() {
        this.$emit('input', false);
        this.$router.push({name: 'redPacket'});
      }
    }
  }
</script>

<style lang="scss">
  @import "../assets/css/funcs.scss";

  .red-packet-pop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, .9);
    .bg, .content {
      position: fixed;
      top: 0;
      left: 0;
      width: 100%;
      height: 100%;
      z-index: 2;
    }
    @keyframes flash {
      from {
        opacity: 0.3;
      }
      to {
        opacity: 0.8;
      }
    }
    .bg {
      background: url("../assets/images/light.png") -30% center no-repeat;
      background-size: cover;
      z-index: 1;
      animation: flash 1s ease-in-out infinite alternate;
    }
    img {
      max-width: 100%;
    }
    .title-placeholder {
      height: 6.75%;
    }
    .body-top-placeholder {
      height: 5.7%;
    }
    .body-bottom-placeholder {
      height: 5%;
    }
    .btns-bottom-placeholder {
      height: 10%;
    }
    .title {
      height: 12.7%;
      img {
        height: 100%;
      }
    }
    .body {
      height: 44%;
      position: relative;
      img {
        height: 100%;
      }
      .money {
        position: absolute;
        bottom: 28%;
        font-size: pxToRem(70px);
        width: 100%;
        color: white;
      }
    }
    .btns {
      display: inline-block;
      position: relative;
      .btn {
        width: pxToRem(250px);
        &:not(:first-child) {
          margin-left: pxToRem(20px);
        }
      }
    }
    .logan {
      font-size: pxToRem(40px);
      color: $yellow;
      img {
        width: 80%;
      }
    }
    @keyframes tap {
      from {
        top: pxToRem(40px);
        right: pxToRem(-30px);
        opacity: 0;
      }
      to {
        opacity: 1;
        top: pxToRem(30px);
        right: pxToRem(-20px);
      }
    }
    .gesture {
      width: pxToRem(68px);
      height: auto !important;
      top: pxToRem(30px);
      right: pxToRem(-20px);
      position: absolute;
      animation: tap 1s infinite;

    }
  }
</style>
